//账号接口
import request from "@/utils/request.js"
//引入qs
import Qs from "qs"

// 最好使用 export暴露，在不同vue使用
//登录
export const login_api = (params) => {
    return request({
        method: 'post',
        url: '/users/checkLogin',
        data: Qs.stringify(params), //用node.js写需要转换   //必须是data
    });
}


//添加账号
export const addAcc_api = (params) => {
    return request({
        method: 'post',
        url: '/users/add',
        data: Qs.stringify(params), //用node.js,php写需要转换   //必须是data
    });
}


//获取账号列表
export const getList_api = (params) => {
    return request({
        methods: 'get',
        url: '/users/list',
        params: params //必须是params,否则出错
    })
}

//删除账号
export const delAcc_api = (params) => {
    return request({
        method: 'get',
        url: '/users/del',
        params: params //必须是params,否则出错
    })
}

//批量删除账号
export const delAccAll_api = (params) => {
    return request({
        method: 'get',
        url: '/users/batchdel',
        params: params //必须是params,否则出错
    })
}

//修改账号
export const editAcc_api = (params) => {
    return request({
        method: 'post',
        url: '/users/edit',
        data: Qs.stringify(params), //用node.js写需要转换   //必须是data
    });
}


//检查旧密码是否正确
export const checkOldPwd_api = (params) => {
    return request({
        method: 'get',
        url: '/users/checkoldpwd',
        params: params //必须是params,否则出错
    })
}

//修改密码
export const editPwd_api = (params) => {
    return request({
        method: 'post',
        url: '/users/editpwd',
        data: Qs.stringify(params), //用node.js写需要转换   //必须是data
    });
}

//获取账号信息
export const getInfo_api = (params) => {
    return request({
        method: 'get',
        url: '/users/info',
        params: params //必须是params,否则出错
    })
}

//头像上传接口

//修改用户头像
export const avatarEdit_api = (params) => {
    return request({
        method: 'get',
        url: '/users/avataredit',
        params: params //必须是params,否则出错
    })
}

//获取用户角色
export const getRole_api = () => {
    return request({
        methods: 'get',
        url: '/users/role',
    })
}